import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

server.bind(("127.0.0.1", 8080))

server.listen(5)

while True:
    client_socket, client_addr = server.accept()
    print(f"连接成功: {client_addr}")
    data = client_socket.recv(1024)
    print("接收到的数据:", data)
    client_socket.send(b"HTTP/1.1 200 OK\r\nserver: FastAPI\r\ncontent-type:application/json;charset=utf-8\r\n\r\n {\"code\":0, \"msg\":\"success\"}")
    client_socket.close()

